package com.ai.trickycards.ui.fragment

import android.os.Bundle
import android.util.DisplayMetrics
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
import com.ai.trickycards.App

abstract class BaseFragment<T : ViewBinding> : Fragment() {

    protected val appViewModel by lazy {
        (requireActivity().application as App).getAppViewModel()
    }

    protected val displayMetrics: DisplayMetrics by lazy {
        requireContext().resources.displayMetrics
    }
    protected lateinit var binding: T

    protected abstract fun getViewBinding(inflater: LayoutInflater, container: ViewGroup?): T

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        binding = getViewBinding(inflater, container)
        return binding.root
    }
}